package sg.edu.nus.dbd.biz;

import java.util.List;

import sg.edu.nus.dbd.dao.ConfigurationDAO;
import sg.edu.nus.dbd.dao.DAOFactory;
import sg.edu.nus.dbd.formbean.ThresholdConfig;

/**
 * 
 * @author Ashok Savarimuthu
 * 
 */
public class ConfigurationBiz {
	public List<ThresholdConfig> getThresholdParameters() {
		try {
			ConfigurationDAO conDao = DAOFactory.getInstance()
					.getConfigurationDAO();
			return conDao.getThresholdParameters();
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public ThresholdConfig getThresholdParameter(int thParamId) {
		try {
			ConfigurationDAO conDao = DAOFactory.getInstance()
					.getConfigurationDAO();
			return conDao.getThresholdParameter(thParamId);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

	public boolean updateThresholdConfig(ThresholdConfig config) {
		try {
			ConfigurationDAO conDao = DAOFactory.getInstance()
					.getConfigurationDAO();
			return conDao.updateThresholdConfig(config);
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
	}

	public ThresholdConfig getThresholdParameter(String paramName) {
		try {
			ConfigurationDAO conDao = DAOFactory.getInstance()
					.getConfigurationDAO();
			return conDao.getThresholdParameter(paramName);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}
}
